// 退出变最小化系统托盘
#ifndef SYSTEMTRAY_H
#define SYSTEMTRAY_H

#include <QMenu>
#include <QObject>
#include <QSystemTrayIcon>

class SystemTray : public QObject
{
    Q_OBJECT
public:
    explicit SystemTray(QObject *parent = nullptr);
    void setupTrayIcon(QWidget *trayWindow);
    bool isVisible() const { return trayIcon->isVisible(); }

signals:
    void restoreHandler();
    void quitHandler();

public slots:
    void onTrayActivated(QSystemTrayIcon::ActivationReason reason);

private:
    QSystemTrayIcon *trayIcon;  // 缩小图标
    QMenu *trayMenu;            // 托盘菜单
    QAction *restoreAction;     // 恢复窗口
    QAction *quitAction;        // 退出应用
    QWidget *trayWindow;        // 接入主窗口
};

#endif // SYSTEMTRAY_H
